using System;
using CStock;
using CUtil;
using System.Diagnostics;
using System.ComponentModel;

namespace CStock
{
	
	//[System.Xml.Serialization.XmlRootAttribute("TradeCondition", Namespace="", IsNullable=false)]
	public class Order  : StockObjectBase, IOrder 
    {


        protected string traderID;
        //protected string dataClassID;
        protected DateTime dateOrder;
        protected DateTime dateDue;
        protected int numberOfItems;
        protected OrderType orderType;
        protected double bid;
        protected string bidOnIndicator;
        protected double bidOnIndicatorValue;
        
        



        #region IOrder Members

        string IOrder.TraderID
        {
            get
            {
                return traderID;
            }
            set
            {
                traderID = value;
            }
        }
        public OrderType OrderType
        {
            get
            {
                return orderType;
            }
            set
            {
                orderType = value;
            }
        }
        public double Bid
        {
            get
            {
                return bid;
            }
            set
            {
                bid = value;
            }
        }
        string IOrder.BidOnIndicator
        {
            get
            {
                return bidOnIndicator;
            }
            set
            {
                bidOnIndicator = value;
            }
        }
        double IOrder.BidOnIndicatorValue
        {
            get
            {
                return bidOnIndicatorValue;
            }
            set
            {
                bidOnIndicatorValue = value;
            }
        }
        
        DateTime IOrder.DateOrder
        {
            get
            {
                return dateOrder;
            }
            set
            {
                dateOrder = value;
            }
        }

        DateTime IOrder.DateDue
        {
            get
            {
                return dateDue;
            }
            set
            {
                dateDue = value;
            }
        }

        int IOrder.NumberOfItems
        {
            get
            {
                return numberOfItems;
            }
            set
            {
                numberOfItems = value;
            }
        }

        double IOrder.GetOrderValue(DateTime dateCurrent)
        {
            //DataClass dc = new DataClassDaily();
            DataClassFactory dataClassFactory = new DataClassFactory();
            dataClassFactory.StockObjectBase.ID = this.iD;

            //this.dataClassFactory.StockObject.ID = shareName;
            Debug.Assert(dataClassFactory.DeSerialize());

            DataClass dc = dataClassFactory.StockObjectBase as DataClass;
            double requestedQuote = dc.QuoteCollection[dateCurrent].CLOSEc;
            return requestedQuote * this.numberOfItems;



            //throw new Exception("The method or operation is not implemented.");
        }
        public override object Clone()
        {
            return this.MemberwiseClone();
        }
        public override string  ToString()
        {

            string str = string.Empty;
            if (this.iD != null)
                str += this.iD;

            if (this.traderID != null)
                str += ";" + this.traderID;
            return str;

        }
    
        #endregion
    }
}
